<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

  <body>
    <div id="root"></div>
    <script type="text/babel">
      class Hello extends React.Component {
        constructor(){
        super()
        this.state = {
            name:'王五',
            age:12,
            flog:false
          }
          this.updateAge = this.updateAge.bind(this)
          this.updateFlog = this.updateFlog.bind(this)
        }
          
          updateFlog(){
            this.setState({
              flog:!this.state.flog
            })
          }
          updateAge(){
            this.setState({
              age:this.state.age+1
            })
          }
        render(){
          return <div>
            <h1>我是一个有状态组件</h1>
            <p>姓名：{this.state.name}</p>
            <p>年龄：{this.state.age}</p>
            <p>职业：前端开发</p>
            <button onClick={this.updateAge}>点击年龄+1</button>
            <button onClick={this.updateFlog}>{this.state.flog?'YES':'NO'}</button>
            </div>
        }
      }
      ReactDOM.render(<Hello />, document.getElementById('root'))
    </script>
  </body>
</html>
